package com.cqhfan.common.autoconfigure.mvc;

import com.cqhfan.common.autoconfigure.mvc.advice.CommonExceptionHandler;
import com.cqhfan.common.autoconfigure.mvc.advice.GlobalResultHandler;
import com.cqhfan.common.autoconfigure.mvc.properties.AuthProperties;
import com.cqhfan.common.autoconfigure.mvc.properties.SecurityProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.DispatcherServlet;

/**
 * @author 眭传洪
 * @create 2024-11-14 19:22
 */
@Configuration
@ConditionalOnClass(DispatcherServlet.class)  // 单体架构没关系，如果是微服务架构并且用的gateway网关必须加这个
public class SpringMvcConfig {

    @Bean
    public CommonExceptionHandler commonExceptionHandler() {
        return new CommonExceptionHandler();
    }

    @Bean
    public GlobalResultHandler globalResultHandler() {
        return new GlobalResultHandler();
    }

    @Bean
    public SecurityProperties securityProperties() {
        return new SecurityProperties();
    }

    @Bean
    public AuthProperties authProperties() {
        return new AuthProperties();
    }

}
